import Events from './index';
import Http from "common/Http";
import Store from "common/Store";
export default class Event1 extends Events {
  static _ins: Event1
  static get instance(): Event1 {
    return this._ins || new Event1;
  }
  constructor() {
    super();
    Event1._ins = this
  }

  /**
   * 活动键值
   */
  protected _eventIndex = 0

  queryEvent(tag, params?) {
    var datas: any = {
      groupId: Events.groupId,
      actId: this.actId,
      token: Store.instance.map.userInfo.token
    }
    switch (tag) {
      case INFO:
        datas.rewardId = this.rewardId.last
        break;
      case JOIN:
        datas.rewardId = this.rewardId.last
        break;
    }
    return Http.instance.getActivity(tag, datas).then(data => {
      var is200 = data.code === 200
      switch (tag) {
        case INFO:
          this.info = is200 ? data.state : null
          break;
        case CDKEYS:
          this.history = is200 ? data.state : []
      }
      return data
    })
  }

}
